1. Field of the Invention
The present invention relates to input buffer management of the playback control for MP3 (Motion Pictures Experts Group Layer III Audio) players. More specifically, a method that initially stores incomplete main_data from MP3 frames in the input buffer until enough main_data is available to correctly decode a frame, allowing the decoding of an MP3 file beginning at an entry point in the MP3 file other than the start of the MP3 file is disclosed.
2. Description of the Prior Art
MPEG-1 audio layer III (MP3) is an ISO/IEC (International Organization for Standardization and International Electrotechnical Commission) standard of audio coding with high quality as well as high efficiency.
FIG. 1 is a block diagram of a traditional MP3 player 10 for reading MP3 files from medium sources such as an optical disk. The MP3 player 10 has a parser 101, an input buffer 102, and an MP3 decoder 103. The MP3 decoder 103 decodes the frames moved from the medium source to the input buffer 102 by the parser.
Referring to FIG. 2, an MP3 file contains a number of frames. Each frame is a unit of data that is enough for decoding and generating a certain amount of audio samples. Take frame 7 for example. The frame 7 includes a header 71, an error check 72, a sample data 73, and an external data 74. The header 71 is a 32-bit stream including a 12-bit synchronization word. In addition, the header 71 has 2 bits for sampling frequency, 4 bits for bitrate, and other information. The error check 72 is an optional 16-bit stream for error detection. Sample data 73 includes necessary information for decoding audio samples of this frame. External data 74 includes data other than audio information. Sample data 73 includes main_data_begin 731 audio_data 732, and main—data 733. The main_data_begin 731 will be described later. The audio_data 732 contains parametric information about the decoding algorithm and main_data 733 contains data of the encoded audio samples. The size of audio_data 732 and main_data 733 may vary in different frames. Although the contents and size of frames may vary from frame to frame, each of the frames, such as frames 1, 4, 5, 6, 7, and 8 shown in FIG. 2, comprise the same structure, for example each of the frames 1, 4, 5, 6, and 8 comprise a main—data field corresponding to the main_data 733 of frame 7 and a main_data_begin field corresponding to the main_data_begin 731 of FIG. 7.
Not all kinds of audio information require the same amount of space after compression. For example, a certain time duration of silence requires less storage space than the same time duration of complex orchestra music when being compressed. Therefore when encoding a bit stream of MP3, the MP3 standard allows an overflow of the main data 733 from one frame into the unused space of prior frames so as to fully utilize the bandwidth.
For example, the size of the main_data 733 of a certain frame is 100 bytes and the required size of the audio samples is 203 bytes. The 103 bytes of overflow will be allocated to a main_data of prior frames, such as a main_data of a frame 6. If the size of the main—data of frame 6 is still not enough for storage of the 103 bytes, a main_data of a frame 5 will be used. The main_data_begin 731 will have a value of 103 indicating the size of the overflow is 103 bytes. If the size of the main_data of frame 6 is only 70 bytes, then there will still be another 33 bytes of overflow. The 33 bytes of overflow will again be allocated to the main_data of the frame 5. To avoid an error, the MP3 standard requests that the main_data_begin of the first frame of an MP3 file, which is frame 1 in FIG. 2, must be zero.
To correctly decode the frames, the MP3 decoder 103 may need the data of several frames beforehand when decoding a particular frame. Thus, the MP3 decoder 103 prefers to decode the frames including the first frame of the MP3 file. However, in some playback modes, such as AB repeat mode or reverse mode, the parser 101 may provide frames which do not start from the first frame of the MP3. In some other cases, the MP3 file is damaged and the main_data_begin does not have a correct value. Since the traditional MP3 decoder 103 directly decodes all the frames regardless of the content of the main_data_begin of the frame, the decoder 103 cannot correctly decode the frames and a “bang” noise may occur as the MP3 player 10 starts playing.